FROM reg.aixbx.com/library/openjdk:8-tini

#配置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ARG JAR_FILE
ARG PROJECT_NAME
ARG MODULE_NAME
ARG PROFILE
ENV JVM_SERVER_OPTS="-XX:MetaspaceSize=256M \
 -XX:MaxMetaspaceSize=256M \
 -XX:+DisableExplicitGC \
 -XX:SurvivorRatio=8 \
 -XX:+UseConcMarkSweepGC \
 -XX:+UseParNewGC \
 -XX:+CMSParallelRemarkEnabled \
 -XX:+CMSClassUnloadingEnabled \
 -XX:LargePageSizeInBytes=128M \
 -XX:+UseFastAccessorMethods \
 -XX:+UseCMSInitiatingOccupancyOnly \
 -XX:CMSInitiatingOccupancyFraction=80 \
 -XX:SoftRefLRUPolicyMSPerMB=0 \
 -XX:+PrintClassHistogram \
 -XX:+PrintGCTimeStamps \
 -XX:+PrintHeapAtGC \
 -XX:+PrintGCDetails \
 -XX:+PrintGCDateStamps \
 -XX:+PrintGCApplicationStoppedTime"

WORKDIR /data
VOLUME ["/data/logs"]
VOLUME ["/data/gclogs"]
ENV PROJECT_NAME=${PROJECT_NAME}
ENV MODULE_NAME=${MODULE_NAME}
ENV JAVA_OPTS="-server -Xms512m -Xmx512m -Xmn256m -Xss256k"
ENV JAVA_SECURITY_EGD="-Djava.security.egd=file:/dev/./urandom"
ENV JVM_GC_LOG="-XX:ErrorFile=/data/gclogs/${PROJECT_NAME}-${MODULE_NAME}-ERR.log -Xloggc:/data/gclogs/${PROJECT_NAME}-${MODULE_NAME}-GC.log"

ENV JAVA_SPRING_PROFILE=${PROFILE}
ADD $JAR_FILE app.jar
COPY ./docker-entrypoint.sh /data/docker-entrypoint.sh
RUN chmod +x /data/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/tini", "--","/data/docker-entrypoint.sh"]
